/**
 * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.cms.link.service;

import com.jeeplus.cms.util.CmsCacheUtils;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.cms.link.entity.CmsLink;
import com.jeeplus.modules.cms.link.mapper.CmsLinkMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 链接Service
 *
 * @author Sawyer
 * @version 2020-11-21
 */
@Service
@Transactional(readOnly = true)
public class CmsLinkService extends CrudService<CmsLinkMapper, CmsLink> {

    @Override
    public CmsLink get(String id) {
        return super.get(id);
    }

    @Override
    public List<CmsLink> findList(CmsLink cmsLink) {
        return super.findList(cmsLink);
    }

    @Override
    public List<CmsLink> findAllList(CmsLink entity) {
        return findList(entity);
    }

    @Override
    public Page<CmsLink> findPage(Page<CmsLink> page, CmsLink cmsLink) {
        return super.findPage(page, cmsLink);
    }

    @Transactional(readOnly = false)
    @Override
    public void save(CmsLink cmsLink) {
        super.save(cmsLink);

        // 清除缓存
        CmsCacheUtils.removeCacheBySiteId(CmsCacheUtils.LINK_LIST_CACHE, cmsLink.getSiteId());
    }

    @Transactional(readOnly = false)
    @Override
    public void delete(CmsLink cmsLink) {
        String siteId = get(cmsLink.getId()).getSiteId();
        super.delete(cmsLink);
        // 清除缓存
        CmsCacheUtils.removeCacheBySiteId(CmsCacheUtils.LINK_LIST_CACHE, siteId);
    }

}
